    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>test</title>
    </head>
    <body>
    <div>
        <a href="tel:110">拨打电话</a>
        <input  accept="image/*" type="file">
    </div>
    <!-- <video autoplay id="video"></video> -->
    <!--video用于显示媒体设备的视频流，自动播放-->
<video id="video" autoplay style="width: 480px;height: 320px"></video>
<!--拍照按钮-->
<div>
<button id="capture">拍照</button>
</div>
<!--描绘video截图-->
<canvas id="canvas" width="480" height="320"></canvas>
    <script>
//     var video=document.getElementById('video')
//     function successCallback(stream) {
//   // 此处利用该 window.URL 对象的 createObjectURL 方法将 blob 转为 url。
//   if (navigator.getUserMedia) {
//       navigator.getUserMedia({"video":{width:400,height:400}},function (stream) {
//           MediaStreamTrack=typeof stream.stop==='function'?stream:stream.getTracks()[1];
//           try{
//               video.src=window.URL.createObjectURL(stream);
//           }catch(e){
//               video.srcObject=stream;
//           }
//       },errorCallback)
//   }
// }
// function errorCallback(error) {
//   console.log('navigator.getUserMedia error: ', error);
// }
//     navigator.mediaDevices.getUserMedia(video).then(function(stream) {
//         successCallback
//     }).catch(function(err) {
//             if (navigator.getUserMedia) {
//     navigator.getUserMedia({video: true}, successCallback, errorCallback);
//     } else {
//     console.log('getUserMedia() is not supported in your browser')
//     video.src = 'somevideo.webm'; // fallback.
//     }
//     });
//访问用户媒体设备的兼容方法
function getUserMedia(constrains,success,error){
    if(navigator.mediaDevices.getUserMedia){
        //最新标准API
        navigator.mediaDevices.getUserMedia(constrains).then(success).catch(error);
    } else if (navigator.webkitGetUserMedia){
        //webkit内核浏览器
        navigator.webkitGetUserMedia(constrains).then(success).catch(error);
    } else if (navigator.mozGetUserMedia){
        //Firefox浏览器
        navagator.mozGetUserMedia(constrains).then(success).catch(error);
    } else if (navigator.getUserMedia){
        //旧版API
        navigator.getUserMedia(constrains).then(success).catch(error);
    }
}

var video = document.getElementById("video");
var canvas = document.getElementById("canvas");
var context = canvas.getContext("2d");

//成功的回调函数
function success(stream){
    //兼容webkit内核浏览器
    var CompatibleURL = window.URL || window.webkitURL;
    //将视频流设置为video元素的源
    video.src = CompatibleURL.createObjectURL(stream);
    //播放视频
    video.play();
}

//异常的回调函数
function error(error){
    // console.log("访问用户媒体设备失败：",error.name,error.message);
}
if (navigator.mediaDevices.getUserMedia || navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia){
    //调用用户媒体设备，访问摄像头
    getUserMedia({
        video:{width:480,height:320}
    },success,error);
} else {
    alert("你的浏览器不支持访问用户媒体设备");
}

//注册拍照按钮的单击事件
document.getElementById("capture").addEventListener("click",function(){
    //绘制画面
    context.drawImage(video,0,0,480,320);
});
    </script>
    </body>
    </html>